
import struct
from packet import Packet

UDP_PROTOCOL = 17

class UDP(Packet):
    def __init__(self, src_port, dst_port, data):
        Packet.__init__(self)
        
        # set local members
        self.m_src_port = src_port
        self.m_dst_port = dst_port
        self.m_data = data
        
        # build headers
        self.m_header = struct.pack("!HH", self.m_src_port, self.m_dst_port)
        self.m_header += struct.pack("!HH", len(self.m_data) + 8, 0)           # (length, checksum)
        
        self._fix_hdr_checksum()
        
    def _fix_hdr_checksum(self):
        pass